package net.lovesrc.allin.jobs.backup;

import com.alibaba.fastjson.JSONObject;
import net.lovesrc.allin.biz.lbc.BaseLbcService;
import net.lovesrc.allin.biz.lbc.LbcService;
import org.apache.commons.lang3.RandomUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Profile;

//@Component
@Profile("geliclive")
public class LbcLotteryJob extends LbcBaseJob {

    @Autowired
    private LbcService lbcService;

    @Override
    public void runOnce() throws Exception {
        {
            JSONObject row = queryForRow(jdbcTemplate,
                    "select mobile from t_lbc_account" +
                            " where goldAccount >= 5 and goldAccount < 20" +
                            " and repeatBuyKjTime is null and worked=1 and mine=0 order by goldAccount limit 1");
            if (row != null) {
                lbcService.lottery(row.getString("mobile"), BaseLbcService.Proxy.PROXY_GELIC);
            }
        }
    }

    @Override
    protected long intervalMilliseconds() {
        return 1000 * RandomUtils.nextInt(3, 5);
    }

}
